package example2;

import common.ListNode;

//141. 环形链表
public class LeetCode141 {
    public static void main(String[] args) {

    }
}

class Solution141 {
    public boolean hasCycle(ListNode head) {
        if(head == null)    return false;
        ListNode slow = head;
        ListNode fast = head;
        while(fast.next != null && fast.next.next != null){
            slow = slow.next;
            fast = fast.next.next;
            if(slow == fast)    return true;
        }
        return false;
    }
}
